<?PHP
    require_once("DButil.php");
    $conn = getConn();
    $sql = "select p_name,p_price,p_unit,p_image_url,p_status from t_product";
    $result = mysqli_query($conn, $sql);

    $sql1 = "select p_name,p_price,p_unit,p_image_url,p_status from t_product where p_id=1";
    $result1 = mysqli_query($conn, $sql1);
    $row1 = mysqli_fetch_assoc($result1);
    // print_r($row1) ;
    // echo $row1["p_name"];
    if($row1["p_status"]){
        $zt1="上架";
    }else{
        $zt1="下架";
    }

    $sql2 = "select p_name,p_price,p_unit,p_image_url,p_status from t_product where p_id=2";
    $result2 = mysqli_query($conn, $sql2);
    $row2 = mysqli_fetch_assoc($result2);
    // print_r($row2) ;
    // echo $row2["p_name"];
    if($row2["p_status"]){
        $zt2="上架";
    }else{
        $zt2="下架";
    }

    $sql3 = "select p_name,p_price,p_unit,p_image_url,p_status from t_product where p_id=3";
    $result3 = mysqli_query($conn, $sql3);
    $row3 = mysqli_fetch_assoc($result3);
    // print_r($row3) ;
    // echo $row3["p_name"];
    if($row3["p_status"]){
        $zt3="上架";
    }else{
        $zt3="下架";
    }

    $sql4 = "select p_name,p_price,p_unit,p_image_url,p_status from t_product where p_id=4";
    $result4 = mysqli_query($conn, $sql4);
    $row4 = mysqli_fetch_assoc($result4);
    // print_r($row4) ;
    // echo $row4["p_name"];
    if($row4["p_status"]){
        $zt4="上架";
    }else{
        $zt4="下架";
    }

    $sql5 = "select p_name,p_price,p_unit,p_image_url,p_status from t_product where p_id=5";
    $result5 = mysqli_query($conn, $sql5);
    $row5 = mysqli_fetch_assoc($result5);
    // print_r($row5) ;
    // echo $row5["p_name"];
    if($row5["p_status"]){
        $zt5="上架";
    }else{
        $zt5="下架";
    }

    $sql6= "select p_name,p_price,p_unit,p_image_url,p_status from t_product where p_id=6";
    $result6 = mysqli_query($conn, $sql6);
    $row6 = mysqli_fetch_assoc($result6);
    // print_r($row6) ;
    // echo $row6["p_name"];
    if($row6["p_status"]){
        $zt6="上架";
    }else{
        $zt6="下架";
    }
?>


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>商品管理</title>
    <style>
        *{
            padding:0;
            margin:0;    
        }
        .top{
            height:30px;
            /* border:1px solid red; */
            background:gray;
            color:white;
            /* text-align:center; */
            line-height:30px;
            display:flex;
        }
        .order{
            position:absolute;
            right:100px;
        }
        .detail{
            position:absolute;
            right:200px;
        }
        .login{
            position:absolute;
            /* border:1px solid red; */
            right:50px;
            cursor:pointer;
        }
        .body{
            width:70%;
            height:80%;
            /* border:1px solid green; */
            /* display:flex; */
            margin:20px auto;
        }
        .line1,.line2{
            width:100%;
            height:50%;
            /* border:1px solid red; */
            display:flex;
            justify-content: space-around;
            margin:30px auto;
        }
        .box{
            width:200px;
            height:200px;
            background:#ccc;
        }
        .pName{
            width:70%;
            margin:0 auto;
            text-align:center;
            font-size:20px;
            font-weight:bold;
            
        }
        .jg{
            width:80%;
            margin:10px auto;
            display:flex;
            justify-content:space-around;
        }
        .pJG{
            cursor: pointer;
            color:red;
        }
    </style>

</head>
<body>
    <?php
        $loginName = $_REQUEST["loginName"];
        $_SESSION["name"] = $loginName;
        $_SESSION["p_name1"]=$row1["p_name"];
        $_SESSION["p_price1"]=$row1["p_price"];
        $_SESSION["p_unit1"]=$row1["p_unit"];

        $_SESSION["p_name2"]=$row2["p_name"];
        $_SESSION["p_price2"]=$row2["p_price"];
        $_SESSION["p_unit2"]=$row2["p_unit"];

        $_SESSION["p_name3"]=$row3["p_name"];
        $_SESSION["p_price3"]=$row3["p_price"];
        $_SESSION["p_unit3"]=$row3["p_unit"];

        $_SESSION["p_name4"]=$row4["p_name"];
        $_SESSION["p_price4"]=$row4["p_price"];
        $_SESSION["p_unit4"]=$row4["p_unit"];

        $_SESSION["p_name5"]=$row5["p_name"];
        $_SESSION["p_price5"]=$row5["p_price"];
        $_SESSION["p_unit5"]=$row5["p_unit"];

        $_SESSION["p_name6"]=$row6["p_name"];
        $_SESSION["p_price6"]=$row6["p_price"];
        $_SESSION["p_unit6"]=$row6["p_unit"];
    ?>
<form action="order.php" method="post"  enctype="multipart/form-data">
    <div>
        <div class="top">
        <a href="./detail.php" class="detail">订单查询</a>
            <a href="./order.php" class="order">购物车</a>
            <div class="login"><?=$loginName?></div>
        </div>
        <div class="body">
            <div class="line1">
                <div class="box">
                    <img src="./image/backimage.jpg" style="width:200px;">
                    <div class="pName"><?=$row1["p_name"]?></div>
                    <div class="jg">
                        <div class="pPerice"><?=$row1["p_price"]?></div>
                        <div class="pUnit"><?=$row1["p_unit"]?></div>
                        <div class="pStatus"><?=$zt1?></div>
                        <!-- <div class="pJG" >加购</div> -->
                        <a class="pJG" href="order1.php">加购</a>
                    </div>
                </div> 
                <div class="box">
                    <img src="./image/backimage.jpg" style="width:200px;">
                    <div class="pName"><?=$row2["p_name"]?></div>
                    <div class="jg">
                        <div class="pPerice"><?=$row2["p_price"]?></div>
                        <div class="pUnit"><?=$row2["p_unit"]?></div>
                        <div class="pStatus"><?=$zt2?></div>
                        <a class="pJG" href="order2.php">加购</a>
                    </div>
                </div>
                <div class="box">
                    <img src="./image/backimage.jpg" style="width:200px;">
                    <div class="pName"><?=$row3["p_name"]?></div>
                    <div class="jg">
                        <div class="pPerice"><?=$row3["p_price"]?></div>
                        <div class="pUnit"><?=$row3["p_unit"]?></div>
                        <div class="pStatus"><?=$zt3?></div>
                        <a class="pJG" href="order3.php">加购</a>
                    </div>
                </div>
            </div>
            <div class="line2">
                <div class="box">
                    <img src="./image/backimage.jpg" style="width:200px;">
                    <div class="pName"><?=$row4["p_name"]?></div>
                    <div class="jg">
                        <div class="pPerice"><?=$row4["p_price"]?></div>
                        <div class="pUnit"><?=$row4["p_unit"]?></div>
                        <div class="pStatus"><?=$zt4?></div>
                        <a class="pJG" href="order4.php">加购</a>
                    </div>
                </div>
                <div class="box">
                    <img src="./image/backimage.jpg" style="width:200px;">
                    <div class="pName"><?=$row5["p_name"]?></div>
                    <div class="jg">
                        <div class="pPerice"><?=$row5["p_price"]?></div>
                        <div class="pUnit"><?=$row5["p_unit"]?></div>
                        <div class="pStatus"><?=$zt5?></div>
                        <a class="pJG" href="order5.php">加购</a>
                    </div>
                </div>
                <div class="box">
                    <img src="./image/backimage.jpg" style="width:200px;">
                    <div class="pName"><?=$row6["p_name"]?></div>
                    <div class="jg">
                        <div class="pPerice"><?=$row6["p_price"]?></div>
                        <div class="pUnit"><?=$row6["p_unit"]?></div>
                        <div class="pStatus"><?=$zt6?></div>
                        <a class="pJG" href="order6.php">加购</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</form>
</body>
</html>


